/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * The software in this package is published under the terms of the GPL v2.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE-GPL.txt file.
 */

package org.cemantika.infrastructure.dao;

import java.util.List;

import org.cemantika.infrastructure.model.PersistentEntity;

/**
 * IBaseDao represents the interface definition of the data access layer of CEManTIKA. Used when
 * the persistence is active.
 * 
 * @author andersonfellipe
 */
public interface IBaseDao<Entity extends PersistentEntity> {
    
    /**
    * Saves an instance of the persistent entity in the system database.
    * 
    * @param obj the instance that is inserted.
    * @return the entity.
    */
   Entity save(Entity obj);

   /**
    * Update an instance of the persistent entity in the system database.
    * 
    * @param obj the instance that is updated.
    * @return the entity.
    */
   Entity update(Entity obj);

   /**
    * Remove an instance of the persistent entity in the system database.
    * 
    * @param obj the instance that is updated.
    */
   void delete(Entity obj);

   /**
    * Retrieve all instances of the entity in the database.
    * 
    * @return a {@link List} with the results.
    */
   List<Entity> findAll();

   /**
    * Perform a search in the database through query passed as parameter.
    * 
    * @param queryString the query.
    * @return an {@link List} with the results.
    */
   List<Entity> find(String queryString);

   /**
    * Find an entity by primary key.
    * 
    * @param identifier the instance of primary key.
    * @return the entity.
    */
   Entity findById(Object identifier);
   
}
